package com.canaan.business.controller.pc.agv;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

import com.canaan.business.domain.agv.AgvRcsRecord;
import com.canaan.business.service.agv.IAgvRcsRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.canaan.common.annotation.Log;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.core.domain.R;
import com.canaan.common.core.page.TableDataInfo;
import com.canaan.common.enums.BusinessType;
import com.canaan.common.utils.poi.ExcelUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * rcs调用记录Controller
 *
 * @author
 * @date 2023-03-02
 */
@Api(tags = "rcs调用记录")
@RestController
@RequestMapping("/wcs/agvRcsRecord")
public class AgvRcsRecordController extends BaseController {
    @Resource
    private IAgvRcsRecordService agvRcsRecordService;

    /**
     * 查询rcs调用记录列表
     */
    @ApiOperation(value = "查询rcs调用记录列表")
    @PreAuthorize("@ss.hasPermi('wcs:agvRcsRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(AgvRcsRecord agvRcsRecord) {
        startPage();
        List<AgvRcsRecord> list = agvRcsRecordService.selectAgvRcsRecordList(agvRcsRecord);
        return getDataTable(list);
    }

    /**
     * 导出rcs调用记录列表
     */
    @ApiOperation(value = "导出rcs调用记录列表")
    @PreAuthorize("@ss.hasPermi('wcs:agvRcsRecord:export')")
    @Log(title = "rcs调用记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AgvRcsRecord agvRcsRecord) {
        List<AgvRcsRecord> list = agvRcsRecordService.selectAgvRcsRecordList(agvRcsRecord);
        ExcelUtil<AgvRcsRecord> util = new ExcelUtil<AgvRcsRecord>(AgvRcsRecord.class);
        util.exportExcel(response, list, "rcs调用记录数据");
    }

    /**
     * 获取rcs调用记录详细信息
     */
    @ApiOperation(value = "获取rcs调用记录详细信息")
    @PreAuthorize("@ss.hasPermi('wcs:agvRcsRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(agvRcsRecordService.selectAgvRcsRecordById(id));
    }

    /**
     * 新增rcs调用记录
     */
    @ApiOperation(value = "新增rcs调用记录")
    @PreAuthorize("@ss.hasPermi('wcs:agvRcsRecord:add')")
    @Log(title = "rcs调用记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AgvRcsRecord agvRcsRecord) {
        return toAjax(agvRcsRecordService.insertAgvRcsRecord(agvRcsRecord));
    }

    /**
     * 修改rcs调用记录
     */
    @ApiOperation(value = "修改rcs调用记录")
    @PreAuthorize("@ss.hasPermi('wcs:agvRcsRecord:edit')")
    @Log(title = "rcs调用记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AgvRcsRecord agvRcsRecord) {
        return toAjax(agvRcsRecordService.updateAgvRcsRecord(agvRcsRecord));
    }

    /**
     * 删除rcs调用记录
     */
    @ApiOperation(value = "删除rcs调用记录")
    @PreAuthorize("@ss.hasPermi('wcs:agvRcsRecord:remove')")
    @Log(title = "rcs调用记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(agvRcsRecordService.deleteAgvRcsRecordByIds(ids));
    }

    /**
     * 重发
     *
     * @param id id
     * @return com.canaan.wcs.entity.agv.AgvRcsRecordEntity
     * @author
     */
    @PutMapping("/{id}")
    @ApiOperation(value = "重发", notes = "重发")
    public R get(
            @ApiParam(name = "id", value = "id")
            @PathVariable Long id) {
        return R.ok(agvRcsRecordService.resetById(id));
    }
}
